<?php

namespace app\common\model;

use think\Db;
use think\Model;

class ScorecModel extends Model
{
    protected $name = 'user_scorec';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = '';
    // 追加属性
    protected $append = [
    ];


    public function scorecU($nums,$user_id,$title){
        $this->save([
            'nums'=>$nums,
            'user_id'=>$user_id,
            'title'=>$title
        ]);
        if($nums > 0){
            Db::name('user')->where('id',$user_id)->inc('scorec',$nums)->update();
        }
        if($nums < 0){
            Db::name('user')->where('id',$user_id)->inc('scorec',$nums)->update();
        }
    }
}